<template>
	<view>
		<!-- 自定义导航栏 -->
		<view class="nabbar" :style="{'height': statusBarHeight + barHeight + 'px'}">
			<!-- //手机状态栏 -->
			<view class="status-bar" :style="{'height': statusBarHeight + 'px'}"></view>
			<!-- //导航栏 -->
			<view class="nabbar-box" :style="{ 'top': statusBarHeight+ 'px', 'heigth': barHeight + 'px' }">
				<view class="nabbar-cont">
					<view>个人中心</view>
				</view>
			</view>
		</view>
		<image class="top-img" src="../../static/profile/top-img.png"></image>
		<view class="top-main">
			<view class="infos">
				<view class="flex head-info align">
					<image class="head-image" src="../../static/profile/head.png"></image>
					<view class="info">
						{{info.username}}
						<view style="font-size: 24rpx;color: ghostwhite;" v-if="infos!=''">到期时间：{{infos.out_date}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="main">
			<view class="cards flex align between">
				<view class="item" @click="toUrl('/pages/task/list')">
					<image src="../../static/profile/icon1.png"></image>
					<view class="nums">{{infos.price}}</view>
					<view>剩余点数</view>
				</view>
				<view class="item" @click="toUrl('/pages/profile/logs')">
					<image src="../../static/profile/icon2.png"></image>
					<view class="nums">{{infos.ai_chat_count}}</view>
					<view>AI创作字数</view>
				</view>
				<!-- <view class="item">
					<view>516</view>
					<view>可提现数</view>
				</view> -->
			</view>
			<view class="cards cards2">
				<view class="card2-tit flex align">基本功能</view>
				<!-- <view class="flex align navs">
					<image src="../../static/profile/icon3.png"></image>
					<view>实名认证</view>
				</view> -->
				<view class="flex align navs" @click="toOut()">
					<image src="../../static/profile/icon4.png"></image>
					<view>退出当前账号</view>
				</view>
			</view>
		</view>
		<!-- 提现弹窗 -->
		<view class="showLody" v-if="show">
			<view class="sh-con">
				<view class="sh-con-tit">提现申请</view>
				<view class="tit2">提现金额</view>
				<view class="flex align price-sh">￥<input v-model="money" placeholder="请输入金额" /></view>
				<view class="tip-show">待提现佣金：￥{{info.money}}</view>
				<view class="show-btns flex align between">
					<view @click="show=false">取消</view>
					<view @click="toDraw()">提交申请</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	// import {
	// 	userDetail,
	// 	checkToken,
	// 	minilogin,
	// 	taskApplyLists,
	// 	withDraw
	// } from '@/api/apiData.js';
	import {
		profileIndex
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				statusBarHeight: 20,
				barHeight: 44,
				barWidth: null,
				info: '',
				total: 0,
				show: false,
				money: '',
				infos:''
			}
		},
		onLoad() {
			let that = this;
			//通过uni自带api获取手机系统信息
			uni.getSystemInfo({
				success: function(res) {
					// console.log(res)
					that.statusBarHeight = res.statusBarHeight; //手机状态栏高度
					let isiOS = res.system.indexOf('iOS') > -1; //是否为iOS系统
					that.barHeight = !isiOS ? 48 : 44; //导航栏高度，iOS：48，Android：44
					that.barWidth = res.windowWidth - 87; //nabbar可操作宽度 = 屏幕宽度 - 小程序右上角的胶囊宽度（87）
				}
			})
		},
		onShow() {
			let info = uni.getStorageSync('lastlogin')
			if (info) {
				this.info = JSON.parse(info)
				this.getInfo()
			} else {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			}

		},
		onReady() {

		},
		onShareAppMessage(res) {

		},
		methods: {
			toOut(){
				uni.showModal({
					title: "提示",
					content: "确定要退出当前账号吗？",
					showCancel: true,
					success: res => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/index'
							})
							uni.clearStorageSync()
						} else {
							
						}
					}
				
				})
			},
			async getInfo() {
				const result = await profileIndex()
				if (result.code == 1) {
					this.infos = result.data.store
				} else {
					uni.showToast({
						title: result.msg,
						icon: 'none'
					})
				}
			},
			toUrl(u) {
				uni.navigateTo({
					url: u
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.showLody {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(0, 0, 0, 0.459);

		.sh-con {
			width: 80%;
			background: white;
			padding: 10rpx 40rpx;
			border-radius: 10rpx;
			font-size: 28rpx;

			.sh-con-tit {
				text-align: center;
				font-weight: bold;
				margin: 10rpx 0 10rpx;
				font-size: 30rpx;
			}

			.price-sh {
				margin: 30rpx 0;
				font-size: 36rpx;
				border-bottom: solid 1rpx gainsboro;
				padding-bottom: 20rpx;

				input {
					margin-left: 10rpx;
				}
			}

			.tip-show {
				color: gray;
			}

			.show-btns {
				padding: 60rpx 0;

				view {
					color: white;
					width: 45%;
					line-height: 2.5;
					text-align: center;
					border-radius: 10rpx;
				}

				view:nth-child(1) {
					background: grey;
				}

				view:nth-child(2) {
					background: #C91717;
				}
			}
		}
	}

	.top-img {
		width: 100%;
		height: 450rpx;
		position: fixed;
		top: 0;
		left: 0;
	}

	.top-main {
		position: relative;
		height: 312rpx;

		// .top-color {
		// 	background: #FF6543;
		// 	height: 88rpx;
		// }



		.infos {
			// position: absolute;
			// width: 90%;
			// top: 130rpx;
			// left: 5%;
			padding: 0 5%;

			.head-info {
				color: white;
				font-size: 26rpx;

				.head-image {
					width: 160rpx;
					height: 160rpx;
					object-fit: cover;
				}

				.info {
					margin-left: 20rpx;
					line-height: 1.8;
					font-size: 32rpx;

					.tab {
						font-size: 24rpx;
						background: #73C917;
						padding: 2rpx 14rpx;
						border-radius: 26rpx;
						margin-top: 24rpx;
						width: fit-content;
					}
				}
			}


		}
	}

	.main {
		position: relative;
		top: -100rpx;
		margin: 24rpx;

		.cards {
			border-radius: 12rpx;
			background: white;
			padding: 34rpx 0;
			margin-bottom: 20rpx;

			.item {
				flex: 1;
				text-align: center;
				color: #AAAAAA;
				font-size: 16rpx;

				.nums {
					font-size: 24rpx;
					font-weight: bold;
					color: #333333;
				}

				image {
					width: 60rpx;
					height: 60rpx;
				}
			}

			.card2-tit {
				font-size: 26rpx;
				font-weight: bold;
				padding: 14rpx 16rpx;

			}

			.navs {
				background: white;
				padding: 29rpx 40rpx;
				font-size: 28rpx;
				margin-bottom: 10rpx;

				image {
					width: 27rpx;
					height: 25rpx;
					margin-right: 10rpx;
				}
			}
		}

		.cards2 {
			padding: 14rpx 16rpx;
			background: none;
		}
	}
</style>